package com.hzncc.scaffold.exception;

import com.hzncc.scaffold.core.ResponseEnum;
import lombok.Getter;
import lombok.ToString;

import java.util.Formatter;

@Getter
@ToString
public class BaseException extends RuntimeException {
  private static final long serialVersionUID = -190834256341033815L;
  public final int code;
  public final String msg;

  public BaseException(int code, String msg) {
    this.code = code;
    this.msg = msg;
  }

  public BaseException(String msg) {
    this.code = ResponseEnum.CODE_9000.getCode();
    this.msg = msg;
  }

  public BaseException(String format, Object... args) {
    //super(new Formatter().format(format, args).toString());
    //this.msg = MessageFormat.format(format, args);
    this.code = ResponseEnum.CODE_9000.getCode();
    this.msg = new Formatter().format(format, args).toString();
  }

}
